/*
 * 文 件    名:  ReviewlistModel.java
 * 创建日期:  2012-12-14下午4:18:57
 * 版          权:  Epro Technologies Co., Ltd. Copyright 2011-2012,  All rights reserved
 * 作          者:  hh084
 */
package com.weipu.common.facade.model;

import java.io.Serializable;
import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.weipu.common.constants.ServerConstant;

/** 
 * @Description 商品评论列表模型
 * @version [版本号, 2012-12-14]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 * 
 * @author hh084
 */
public class ReviewlistModel implements Serializable
{
    
    /**
     * 注释内容
     */
    private static final long serialVersionUID = -1723752946365437555L;
    
    /** 
     * 
     * 主键ID
     *
     */
    private int ID;
    
    /** 
     * 
     * 发布时间
     *
     */
    private String Timestamp;
    
    /** 
     * 
     * 用户名
     *
     */
    private String Username;
    
    /** 
     * 
     * CICID
     *
     */
    private int CICID;
    
    /** 
     * 
     * SKU号码
     *
     */
    private int SKU;
    
    /** 
     * 
     * SKU标题
     *
     */
    private String SKUTital;
    
    /** 
     * 
     * SKU连接地址
     *
     */
    private String SKUUrl;
    
    /** 
     * 
     * 评论标题
     *
     */
    private String Subject;
    
    private String Content;
    /** 
     * 
     * 优点
     *
     */
    private String Pros;
    
    /** 
     * 
     * 缺点
     *
     */
    private String Cons;
    
    /** 
     * 
     * 其他的想法
     *
     */
    private String OtherThoughts;
    
    /** 
     * 
     * 底线
     *
     */
    private String Bottomline;
    
    /** 
     * 
     * 价格评价
     *
     */
    private int PriceRating;
    
    /** 
     * 
     * 易于使用评价
     *
     */
    private int EaseOfUseRating;
    
    /** 
     * 
     * 建立质量评价
     *
     */
    private int BuildQualityRating;
    
    /** 
     * 
     * 价值评级
     *
     */
    private int ValueRating;
    
    /** 
     * 
     * 总体评分
     *
     */
    private int OverallRating;
    
    /** 
     * 
     * Involvement Level
     *
     */
    private String TechLevel;
    
    /** 
     * 
     * Time of Ownership
     *
     */
    private String OwnershipStatus;
    
    //    /** 
    //     * 
    //     * 图片标题
    //     *
    //     */
    //    private String Caption;
    //    
    //    /** 
    //     * 
    //     * 图片宽度
    //     *
    //     */
    //    private int Width;
    //    
    //    /** 
    //     * 
    //     * 图片高度
    //     *
    //     */
    //    private int Height;
    //    
    /** 
     * 
     * 缩略图地址
     *
     */
    private String ThumbURL;
    
    //    
    //    /** 
    //     * 
    //     * 图片地址
    //     *
    //     */
    //    private String PictureURL;
    
    /** 
     * 
     * 经证实的所有者
     *
     */
    private boolean VerifiedOwner;
    
    /** 
     * 
     * 积分奖励数
     *
     */
    private int PointsRewarded;
    
    /** 
     * 
     * 评论回复数
     *
     */
    private int Comments;
    
    /** 
     * 
     * 有用的数
     *
     */
    private int Helpfuls;
    
    //    /** 
    //     * 
    //     * 上级图片ID
    //     *
    //     */
    //    private int ParentID;
    
    public int getID()
    {
        return ID;
    }
    
    public void setID(int iD)
    {
        ID = iD;
    }
    
    public String getTimestamp()
    {
        return Timestamp;
    }
    
    public void setTimestamp(String timestamp)
    {
        Timestamp = timestamp;
    }
    
    public String getUsername()
    {
        return Username;
    }
    
    public void setUsername(String username)
    {
        Username = username;
    }
    
    public int getCICID()
    {
        return CICID;
    }
    
    public void setCICID(int cICID)
    {
        CICID = cICID;
    }
    
    public int getSKU()
    {
        return SKU;
    }
    
    public void setSKU(int sKU)
    {
        SKU = sKU;
    }
    
    public String getSKUTital()
    {
        return SKUTital;
    }
    
    public void setSKUTital(String sKUTital)
    {
        SKUTital = sKUTital;
    }
    
    public String getSKUUrl()
    {
        return SKUUrl;
    }
    
    public void setSKUUrl(String sKUUrl)
    {
        SKUUrl = sKUUrl;
    }
    
    //    public String getCaption()
    //    {
    //        return Caption;
    //    }
    //    
    //    public void setCaption(String caption)
    //    {
    //        Caption = caption;
    //    }
    //    
    //    public int getWidth()
    //    {
    //        return Width;
    //    }
    //    
    //    public void setWidth(int width)
    //    {
    //        Width = width;
    //    }
    //    
    //    public int getHeight()
    //    {
    //        return Height;
    //    }
    //    
    //    public void setHeight(int height)
    //    {
    //        Height = height;
    //    }
    //    
    public String getThumbURL()
    {
        return ThumbURL;
    }
    
    public void setThumbURL(String thumbURL)
    {
        ThumbURL = thumbURL;
    }
    
    //    
    //    public String getPictureURL()
    //    {
    //        return PictureURL;
    //    }
    //    
    //    public void setPictureURL(String pictureURL)
    //    {
    //        PictureURL = pictureURL;
    //    }
    
    public boolean isVerifiedOwner()
    {
        return VerifiedOwner;
    }
    
    public void setVerifiedOwner(boolean verifiedOwner)
    {
        VerifiedOwner = verifiedOwner;
    }
    
    public int getPointsRewarded()
    {
        return PointsRewarded;
    }
    
    public void setPointsRewarded(int pointsRewarded)
    {
        PointsRewarded = pointsRewarded;
    }
    
    public int getComments()
    {
        return Comments;
    }
    
    public void setComments(int comments)
    {
        Comments = comments;
    }
    
    public int getHelpfuls()
    {
        return Helpfuls;
    }
    
    public void setHelpfuls(int helpfuls)
    {
        Helpfuls = helpfuls;
    }
    
    //    public int getParentID()
    //    {
    //        return ParentID;
    //    }
    //    
    //    public void setParentID(int parentID)
    //    {
    //        ParentID = parentID;
    //    }
    
    public String getSubject()
    {
        return Subject;
    }
    
    public void setSubject(String subject)
    {
        Subject = subject;
    }
    
    public String getContent() {
		return Content;
	}

	public void setContent(String content) {
		Content = content;
	}
    
    public String getPros()
    {
        return Pros;
    }
    
    public void setPros(String pros)
    {
        Pros = pros;
    }
    
    public String getCons()
    {
        return Cons;
    }
    
    public void setCons(String cons)
    {
        Cons = cons;
    }
    
    public String getOtherThoughts()
    {
        return OtherThoughts;
    }
    
    public void setOtherThoughts(String otherThoughts)
    {
        OtherThoughts = otherThoughts;
    }
    
    public String getBottomline()
    {
        return Bottomline;
    }
    
    public void setBottomline(String bottomline)
    {
        Bottomline = bottomline;
    }
    
    public int getPriceRating()
    {
        return PriceRating;
    }
    
    public void setPriceRating(int priceRating)
    {
        PriceRating = priceRating;
    }
    
    public int getEaseOfUseRating()
    {
        return EaseOfUseRating;
    }
    
    public void setEaseOfUseRating(int easeOfUseRating)
    {
        EaseOfUseRating = easeOfUseRating;
    }
    
    public int getBuildQualityRating()
    {
        return BuildQualityRating;
    }
    
    public void setBuildQualityRating(int buildQualityRating)
    {
        BuildQualityRating = buildQualityRating;
    }
    
    public int getValueRating()
    {
        return ValueRating;
    }
    
    public void setValueRating(int valueRating)
    {
        ValueRating = valueRating;
    }
    
    public int getOverallRating()
    {
        return OverallRating;
    }
    
    public void setOverallRating(int overallRating)
    {
        OverallRating = overallRating;
    }
    
    public String getTechLevel()
    {
        return TechLevel;
    }
    
    public void setTechLevel(String techLevel)
    {
        TechLevel = techLevel;
    }
    
    public String getOwnershipStatus()
    {
        return OwnershipStatus;
    }
    
    public void setOwnershipStatus(String ownershipStatus)
    {
        OwnershipStatus = ownershipStatus;
    }
    
    /**
     * 产品解析
     * @param json 要解析的产品字符串
     * @return 本地产品对象
     */
    public static ReviewlistModel json2product(JSONObject json)
    {
        if (null == json)
        {
            return null;
        }
        
        ReviewlistModel model = new ReviewlistModel();
        
        model.setID(json.optInt(ServerConstant.ProductReviews.CONSTANT_ID));
        if (json.optString(ServerConstant.ProductReviews.CONSTANT_TIMESTAMP) != JSONObject.NULL
            && !json.isNull(ServerConstant.ProductReviews.CONSTANT_TIMESTAMP))
        {
            model.setTimestamp(json.optString(ServerConstant.ProductReviews.CONSTANT_TIMESTAMP));
        }
        if (json.optString(ServerConstant.ProductReviews.CONSTANT_USERNAME) != JSONObject.NULL
            && !json.isNull(ServerConstant.ProductReviews.CONSTANT_USERNAME))
        {
            model.setUsername(json.optString(ServerConstant.ProductReviews.CONSTANT_USERNAME));
        }
        model.setCICID(json.optInt(ServerConstant.ProductReviews.CONSTANT_CICID));
        model.setSKU(json.optInt(ServerConstant.ProductReviews.CONSTANT_SKU));
        if (json.optString(ServerConstant.ProductReviews.CONSTANT_SKUTITLE) != JSONObject.NULL
            && !json.isNull(ServerConstant.ProductReviews.CONSTANT_SKUTITLE))
        {
            model.setSKUTital(json.optString(ServerConstant.ProductReviews.CONSTANT_SKUTITLE));
        }
        String temp = json.optString(ServerConstant.ProductReviews.CONSTANT_SKUURL);
        model.setSKUUrl(temp);
        if (json.optString(ServerConstant.ProductReviews.CONSTANT_SUBJECT) != JSONObject.NULL
            && !json.isNull(ServerConstant.ProductReviews.CONSTANT_SUBJECT))
        {
            model.setSubject(json.optString(ServerConstant.ProductReviews.CONSTANT_SUBJECT));
        }
        
        if (json.optString(ServerConstant.ProductReviews.CONSTANT_CONTENT) != JSONObject.NULL
                && !json.isNull(ServerConstant.ProductReviews.CONSTANT_CONTENT))
            {
                model.setContent(json.optString(ServerConstant.ProductReviews.CONSTANT_CONTENT));
            }
        if (json.optString(ServerConstant.ProductReviews.CONSTANT_PROS) != JSONObject.NULL
            && !json.isNull(ServerConstant.ProductReviews.CONSTANT_PROS))
        {
            model.setPros(json.optString(ServerConstant.ProductReviews.CONSTANT_PROS));
        }
        if (json.optString(ServerConstant.ProductReviews.CONSTANT_CONS) != JSONObject.NULL
            && !json.isNull(ServerConstant.ProductReviews.CONSTANT_CONS))
        {
            model.setCons(json.optString(ServerConstant.ProductReviews.CONSTANT_CONS));
        }
        if (json.optString(ServerConstant.ProductReviews.CONSTANT_OTHERTHOUGHTS) != JSONObject.NULL
            && !json.isNull(ServerConstant.ProductReviews.CONSTANT_OTHERTHOUGHTS))
        {
            model.setOtherThoughts(json.optString(ServerConstant.ProductReviews.CONSTANT_OTHERTHOUGHTS));
        }
        if (json.optString(ServerConstant.ProductReviews.CONSTANT_BOTTOMLINE) != JSONObject.NULL
            && !json.isNull(ServerConstant.ProductReviews.CONSTANT_BOTTOMLINE))
        {
            model.setBottomline(json.optString(ServerConstant.ProductReviews.CONSTANT_BOTTOMLINE));
        }
        model.setPriceRating(json.optInt(ServerConstant.ProductReviews.CONSTANT_PRICERATING));
        model.setEaseOfUseRating(json.optInt(ServerConstant.ProductReviews.CONSTANT_EASEOFUSERATING));
        if (json.optString(ServerConstant.ProductReviews.CONSTANT_BUILDQUALITYRATING) != JSONObject.NULL
            && !json.isNull(ServerConstant.ProductReviews.CONSTANT_BUILDQUALITYRATING))
        {
            model.setBuildQualityRating(json.optInt(ServerConstant.ProductReviews.CONSTANT_BUILDQUALITYRATING));
        }
        model.setValueRating(json.optInt(ServerConstant.ProductReviews.CONSTANT_VALUERATING));
        model.setOverallRating(json.optInt(ServerConstant.ProductReviews.CONSTANT_OVERALLRATING));
        if (json.optString(ServerConstant.ProductReviews.CONSTANT_OWNERSHIPSTATUS) != JSONObject.NULL
            && !json.isNull(ServerConstant.ProductReviews.CONSTANT_OWNERSHIPSTATUS))
        {
            model.setOwnershipStatus(json.optString(ServerConstant.ProductReviews.CONSTANT_OWNERSHIPSTATUS));
        }
        if (json.optString(ServerConstant.ProductReviews.CONSTANT_TECHLEVEL) != JSONObject.NULL
            && !json.isNull(ServerConstant.ProductReviews.CONSTANT_TECHLEVEL))
        {
            model.setTechLevel(json.optString(ServerConstant.ProductReviews.CONSTANT_TECHLEVEL));
        }
        //        if (json.optString(ServerConstant.ProductReviews.CONSTANT_CAPTION) != JSONObject.NULL
        //                && !json.isNull(ServerConstant.ProductReviews.CONSTANT_CAPTION))
        //        {
        //            model.setCaption(json.optString(ServerConstant.ProductReviews.CONSTANT_CAPTION));
        //        }
        //        model.setWidth(json.optInt(ServerConstant.ProductReviews.CONSTANT_WIDTH));
        //        model.setHeight(json.optInt(ServerConstant.ProductReviews.CONSTANT_HEIGHT));
        temp = json.optString(ServerConstant.ProductReviews.CONSTANT_THUMBURL);
        model.setThumbURL(temp);
        model.setVerifiedOwner(json.optBoolean(ServerConstant.ProductReviews.CONSTANT_VERIFIEDOWNER));
        model.setPointsRewarded(json.optInt(ServerConstant.ProductReviews.CONSTANT_POINTSREWARDED));
        model.setComments(json.optInt(ServerConstant.ProductReviews.CONSTANT_COMMENTS));
        model.setHelpfuls(json.optInt(ServerConstant.ProductReviews.CONSTANT_HELPFULS));
        return model;
    }
    
    /**
     * 产品解析
     * @param json 要解析的产品字符串
     * @return 本地产品对象
     */
    public static ArrayList<ReviewlistModel> jsonarray2product(JSONArray jsonarray)
    {
        ArrayList<ReviewlistModel> reviewlistModels = new ArrayList<ReviewlistModel>();
        for (int i = 0; i < jsonarray.length(); i++)
        {
            ReviewlistModel reviewlistModel = new ReviewlistModel();
            try
            {
                reviewlistModels.add(reviewlistModel.json2product(jsonarray.getJSONObject(i)));
            }
            catch (JSONException e)
            {
                e.printStackTrace();
            }
        }
        return reviewlistModels;
        
    }
    
}
